#include <Windows.h>

class Lock
{
public:
    Lock(CRITICAL_SECTION* cs)
    {
        this->cs = cs;
        EnterCriticalSection(cs);
    }
    ~Lock()
    {
        LeaveCriticalSection(cs);
    }
private:
    CRITICAL_SECTION* cs;
};